import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class RegexTest
{
    static private final Pattern PATTERN_WHERE_VALUE = Pattern.compile("\\?");
    
    public static void main(String[] args)
    {
        String condition = "Mon bnoujour ? bobo : bibi ? yeah man";
        
        Matcher _whereValueMatcher = null;
        
        if (condition != null)
        {
            Object[] unsafeValues = {4, "David"};
            
            if (unsafeValues != null) {
                int counter = 0;
                int size    = unsafeValues.length;
                
                if (_whereValueMatcher == null)
                    _whereValueMatcher = PATTERN_WHERE_VALUE.matcher( condition );
                else
                    _whereValueMatcher.reset( condition );
                
                while ( counter < size ) {
                    condition = _whereValueMatcher.replaceFirst( unsafeValues[counter].toString() );
                    _whereValueMatcher.reset( condition );
                    counter++;
                }
            }
        }
        System.out.println("Condition = " + condition);
    }

}
